﻿using System.Collections.Generic;
using System.Collections.ObjectModel;
using BiljartHandicap.UserWebServiceReference;

namespace BiljartHandicap.ViewModel
{
    public class UserViewModel : ViewModel
    {
        private ObservableCollection<User> _users;

        public IEnumerable<User> Users
        {
            get { return _users; }
        }

        public void LoadUsers()
        {
            var client = new UserWebServiceClient();
            client.GetUsersCompleted += new System.EventHandler<GetUsersCompletedEventArgs>(ClientGetUsersCompleted);
            client.GetUsersAsync();
        }

        void ClientGetUsersCompleted(object sender, GetUsersCompletedEventArgs e)
        {
            _users = e.Result;
            NotifyPropertyChanged("Users");
        }
    }
}
